<template>
  <div class="login">
    <div class="login_context">
      <div class="login_logo">
        <img src="../assets/logo.png">
      </div>
<!--      头部图片-->

    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="login_box">

      <el-form-item label="账号" prop="usercount" >
        <el-input v-model="ruleForm.usercount"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        ruleForm: {
          usercount:'',
          password:''

        },
        rules: {
          usercount: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
          ],
          password:[
            { required: true, message: '请输入密码', trigger: 'blur' },
          ]

        }
      };
    },
    methods: {
      submitForm(formName) {
        const _this=this
        this.$refs[formName].validate((valid) => {
          if (valid) {
            axios.post('http://local' +
              'host:8181/customer/login',this.ruleForm).then(function (resp) {
                //保存当前的token
              // window.sessionStorage.setItem('token',resp.data.data.customer.token)
              _this.$router.push('/managehome')
            })
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>

<style scoped="scoped">



  .login{
    height: 100%;
    background-color: pink;
  }

  .login_context{
    width: 450px;
    height: 300px;
    background:#fff;
    position: absolute;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
    border-radius: 10px;
    box-shadow: 0 0 5px 2px #ddd;
  }

  .login_logo{
    width: 150px;
    height: 150px;
    position: absolute;
    top:-75px;
    left:50%;
    margin-left: -75px;
    border:1px solid #eee;
    border-radius: 50%;
    background: #fff;
    padding: 10px;
    box-shadow:0 0 3px 2px #fff;
  }
  .login_logo img{
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgb(238,238,238);
  }

  .login_box{
    width:100%;
    position: absolute;
    bottom: 0;
    padding: 0 20px;
    box-sizing:border-box;

  }


</style>
